import { WelfareItem } from "./WelfareItem";
import { Cache } from "../../../cache/Cache";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../../extend/language/Language";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { FilterConst } from "../../../../component/gconst/FilterConst";
//class WelCopyExpItem
    
    export  class WelCopyExpItem extends WelfareItem
    {
        constructor()
        {
            super();
            return;
        }

        public updateData(): void
        {
            var loc1=Cache.instance.copy.getCopySingleExp();
            this._expTxt1Count.htmlText = HTMLUtil.addColor(Language.getStringByParam(20550, HTMLUtil.addColor(loc1[0], GlobalStyle.color2)), GlobalStyle.color1);
            this._expTxt1Value.htmlText = HTMLUtil.addColor(Language.getStringByParam(20557, HTMLUtil.addColor(loc1[1], "#ffff00")), GlobalStyle.color1);
            if (loc1[0] > 0) 
            {
                this._getBtn1.enabled = true;
            }
            else 
            {
                this._getBtn1.enabled = false;
            }
            loc1 = Cache.instance.copy.getCopyTeamExp();
            this._expTxt2Count.htmlText = HTMLUtil.addColor(Language.getStringByParam(20550, HTMLUtil.addColor(loc1[0], GlobalStyle.color2)), GlobalStyle.color1);
            this._expTxt2Value.htmlText = HTMLUtil.addColor(Language.getStringByParam(20557, HTMLUtil.addColor(loc1[1], "#ffff00")), GlobalStyle.color1);
            if (loc1[0] > 0) 
            {
                this._getBtn2.enabled = true;
            }
            else 
            {
                this._getBtn2.enabled = false;
            }
            return;
        }

        /* internal  */onGet1ClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.CopyTotalExpGetReq, -2));
            return;
        }

        /* internal  */onGet2ClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.CopyTotalExpGetReq, -3));
            return;
        }

        /* internal  */onShowAllTxtLinkhandler(arg1: Object /* flash.events.TextEvent */): void
        {
            return;
        }

        protected /* override */ initUI(): void
        {
            super.initUI();
            _titleTxt.text = Language.getString(20551);
            _titleTxt2.text = Language.getString(20552);
            this._expTxt1 = new Object /* flash.text.TextField */();
            this._expTxt1.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._expTxt1.mouseEnabled = false;
            this._expTxt1.width = 52;
            this._expTxt1.height = 18;
            this._expTxt1.textColor = 65280;
            this._expTxt1.text = Language.getString(20553);
            this._expTxt1.x = 5;
            this._expTxt1.y = _titleBg2.y + _titleBg2.height + 8;
            addChild(this._expTxt1);
            this._line = GlobalClass.getBitmap(ImagesConst.SplitLine);
            this._line.width = width;
            this._line.y = 117;
            addChild(this._line);
            this._expTxt2 = new Object /* flash.text.TextField */();
            this._expTxt2.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._expTxt2.mouseEnabled = false;
            this._expTxt2.width = 52;
            this._expTxt2.height = 18;
            this._expTxt2.textColor = 65280;
            this._expTxt2.text = Language.getString(20554);
            this._expTxt2.x = this._expTxt1.x;
            this._expTxt2.y = 122;
            addChild(this._expTxt2);
            this._expTxt1Count = new Object /* flash.text.TextField */();
            this._expTxt1Count.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._expTxt1Count.mouseEnabled = false;
            this._expTxt1Count.width = 155;
            this._expTxt1Count.height = 18;
            this._expTxt1Count.x = this._expTxt1.x + this._expTxt1.textWidth + 8;
            this._expTxt1Count.y = this._expTxt1.y;
            addChild(this._expTxt1Count);
            this._expTxt2Count = new Object /* flash.text.TextField */();
            this._expTxt2Count.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._expTxt2Count.mouseEnabled = false;
            this._expTxt2Count.width = 155;
            this._expTxt2Count.height = 18;
            this._expTxt2Count.x = this._expTxt2.x + this._expTxt2.textWidth + 8;
            this._expTxt2Count.y = this._expTxt2.y;
            addChild(this._expTxt2Count);
            this._expTxt1Value = new Object /* flash.text.TextField */();
            this._expTxt1Value.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._expTxt1Value.mouseEnabled = false;
            this._expTxt1Value.width = 155;
            this._expTxt1Value.height = 18;
            this._expTxt1Value.x = this._expTxt1Count.x;
            this._expTxt1Value.y = this._expTxt1Count.y + 27;
            addChild(this._expTxt1Value);
            this._expTxt2Value = new Object /* flash.text.TextField */();
            this._expTxt2Value.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._expTxt2Value.mouseEnabled = false;
            this._expTxt2Value.width = 155;
            this._expTxt2Value.height = 18;
            this._expTxt2Value.x = this._expTxt2Count.x;
            this._expTxt2Value.y = this._expTxt2Count.y + 27;
            addChild(this._expTxt2Value);
            this._getBtn1 = new GButton();
            this._getBtn1.setSize(44, 20);
            this._getBtn1.label = Language.getString(20564);
            this._getBtn1.x = width - this._getBtn1.width - 8;
            this._getBtn1.y = this._expTxt1Value.y;
            this._getBtn1.textField.filters = [FilterConst.glowFilter];
            this._getBtn1.styleName = "Button";
            this._getBtn1.addEventListener(flash.events.MouseEvent.CLICK, this.onGet1ClickHandler);
            addChild(this._getBtn1);
            this._getBtn2 = new GButton();
            this._getBtn2.setSize(44, 20);
            this._getBtn2.label = Language.getString(20564);
            this._getBtn2.x = this._getBtn1.x;
            this._getBtn2.y = this._expTxt2Value.y;
            this._getBtn2.textField.filters = [FilterConst.glowFilter];
            this._getBtn2.styleName = "Button";
            this._getBtn2.addEventListener(flash.events.MouseEvent.CLICK, this.onGet2ClickHandler);
            addChild(this._getBtn2);
            this._showAllTxt = new Object /* flash.text.TextField */();
            this._showAllTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._showAllTxt.width = 80;
            this._showAllTxt.height = 18;
            this._showAllTxt.htmlText = "<u><a href=\'event: 0\'>" + HTMLUtil.addColor(Language.getString(20556), "#00ff00") + "</a></u>";
            this._showAllTxt.x = width - this._showAllTxt.textWidth - 10;
            this._showAllTxt.y = height - this._showAllTxt.textHeight - 10;
            this._showAllTxt.filters = [FilterConst.glowFilter];
            this._showAllTxt.addEventListener(flash.events.TextEvent.LINK, this.onShowAllTxtLinkhandler);
            return;
        }

        /* internal */ /* var */_expTxt1: Object /* flash.text.TextField */;

        /* internal */ /* var */_expTxt2: Object /* flash.text.TextField */;

        /* internal */ /* var */_expTxt1Count: Object /* flash.text.TextField */;

        /* internal */ /* var */_expTxt2Count: Object /* flash.text.TextField */;

        /* internal */ /* var */_expTxt1Value: Object /* flash.text.TextField */;

        /* internal */ /* var */_expTxt2Value: Object /* flash.text.TextField */;

        /* internal */ /* var */_getBtn1: GButton;

        /* internal */ /* var */_getBtn2: GButton;

        /* internal */ /* var */_line: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_showAllTxt: Object /* flash.text.TextField */;
    }
